package com.rmt.www.utility;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;


public class SystemTime {
	private static JdbcTemplate jdbcTemplate;

	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}
	

	public static Date getSystemTime() {
		String sql="select sysdate from dual";
		try{
			Date date=(Date) jdbcTemplate.queryForObject(sql, Date.class);
			
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
			String a=format.format(date);
			Date d=format.parse(a);
			return d;
		}catch(Exception e) {
			e.printStackTrace();
			return null;
		}
		
		
	}
}
